#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/licenses/gpl.txt
from inary.actionsapi import inarytools
from inary.actionsapi import shelltools
from inary.actionsapi import autotools as tools
from inary.actionsapi import get

def setup():
    ops="""--enable-usrdir-path \
           --enable-fs-paths-default=/bin:/usr/bin:/usr/local/bin \
           --disable-chfn-chsh \
           --enable-raw \
           --disable-uuidd \
           --disable-tls \
           --disable-kill \
           --disable-login \
           --disable-last \
           --disable-sulogin \
           --disable-su \
           --without-python \
           --without-udev \
           --disable-hardlink \
           --with-systemdsystemunitdir=no \
           --with-systemd=no \
           --with-selinux=no \
           --with-audit=no \
           --disable-makeinstall-setuid \
           --disable-makeinstall-chown \
       """
    shelltools.export("CFLAGS","")
    if get.buildTYPE() == "emul32":
        shelltools.export("CC","gcc -m32")
        shelltools.export("CXX","g++ -m32")
        shelltools.export("LD","ld -m32")
        shelltools.reset_env()
        tools.configure("--libdir=/lib32 {}".format(ops))
        return
    tools.configure("--libdir=/lib {}".format(ops))
def build():
    if get.buildTYPE() == "emul32":
        shelltools.system("make lib{uuid,blkid,fdisk,mount,smartcols}.la "+get.makeJOBS())
        return
    tools.make()

def install():
    if get.buildTYPE() == "emul32":
        tools.make("install-usrlib_execLTLIBRARIES  install-pkgconfigDATA DESTDIR=%s" % get.installDIR())
        return
    tools.rawInstall("DESTDIR=%s" % get.installDIR())

